package com.cr.business.controller;

import com.cr.business.domain.dto.EntityReqDto;
import com.cr.business.domain.vo.EntityListData;
import com.cr.business.service.ITbUserEntityInfoService;
import com.cr.common.annotation.Log;
import com.cr.common.core.controller.BaseController;
import com.cr.common.core.domain.AjaxResult;
import com.cr.common.core.page.TableDataInfo;
import com.cr.common.enums.BusinessType;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * 主体审核控制器
 */
@RestController
@RequestMapping("/entity/auth")
public class TbUserEntityInfoAuthController extends BaseController {

    @Resource
    private ITbUserEntityInfoService tbUserEntityInfoService;

    /**
     * 查询主体信息审核列表
     */
    @PreAuthorize("@ss.hasPermi('business:entity:auth')")
    @GetMapping("/list")
    public TableDataInfo list(EntityReqDto dto)
    {
        dto.setReqType("auth");
        startPage();
        List<EntityListData> entityListData = tbUserEntityInfoService.selectEntityList(dto);
        return getDataTable(entityListData);
    }

    /**
     * 审核
     */
    @PreAuthorize("@ss.hasPermi('business:auth:operation')")
    @Log(title = "审核主体信息", businessType = BusinessType.UPDATE)
    @PutMapping("/{entityId}")
    public AjaxResult auth(@PathVariable String entityId, String result, String reasons)
    {
        return toAjax(tbUserEntityInfoService.authEntityInfo(entityId, result, reasons));
    }
}
